﻿using System.Web.Mvc;
using System.Web.Routing;

namespace Smarly.Web.Areas.Profile.Helpers
{
	public static class ProfileUrlExtentions
	{
		private const string Protocol = "http";

		private static RouteValueDictionary RouteValue
		{
			get { return new RouteValueDictionary {/*{"area", "Profile"}*/}; }
		}

		private static RouteValueDictionary AddPair(this RouteValueDictionary coll, string key, object value)
		{
			coll.Add(key, value);
			return coll;
		}

		private static string Host(this UrlHelper urlHelper)
		{
			var domains = urlHelper.RequestContext.HttpContext.Request.Url.Host.Split('.');
			return ProfileAreaRegistration.Subdomain + "." + domains[domains.Length - 2] + "." + domains[domains.Length - 1];
		}

		public static string AccountLogin(this UrlHelper urlHelper)
		{
			return urlHelper.RouteUrl("Profile_SignInAccount", RouteValue, Protocol, urlHelper.Host());
		}

		public static string EbookDownload(this UrlHelper urlHelper, string hashTag/*, bool showDownloadPage = false*/)
		{
			const string extention = "pdf";
			return urlHelper.RouteUrl("Profile_Ebook_pdf", RouteValue.AddPair("parts", hashTag + "." + extention).AddPair("extention", extention), Protocol, urlHelper.Host());
		}
	}
}